package com.echat.serviceapigateway.zuul.config;

import com.echat.serviceapigateway.zuul.CustomRouteLocator;
import com.echat.serviceapigateway.security.service.ServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPath;
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by chenmohan on 2018/10/16
 *
 * @description
 */
@Configuration
public class ZuulConfig {

    @Autowired
    ZuulProperties zuulProperties;
    @Autowired
    ServerProperties serverProperties;
    @Autowired
    ServiceService serviceService;
    @Autowired
    DispatcherServletPath dispatcherServletPath;
    @Autowired
    ApplicationContext applicationContext;

    @Bean
    public CustomRouteLocator customRouteLocator(){
       return new CustomRouteLocator(this.serverProperties.getServlet().getServletPrefix(),zuulProperties,serviceService);
    }

}
